package com.itheima.dao;

import com.itheima.domain.Book;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.util.List;

public interface BookDao {
    //查询全部
    @Select("select * from tbl_book")
    public List<Book> findAllBooks();
    //查询id
    @Select("select * from tbl_book where id=#{id}")
    public Book findById(Integer id);
    //增加数据
    @Insert("insert into tbl_book (type,name,description) values(#{type},#{name},#{description})")
    public int saveBooks(Book book);
    //修改数据
    @Update("update tbl_book set type = #{type},name=#{name},description=#{description} where id=#{id}")
    public int updateBooks(Book book);
    //删除数据
    @Delete("delete from tbl_book where id = #{id}")
    public int deleteById(Integer id);
}
